package com.mike.employment.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mike.employment.base.ApiResult;
import com.mike.employment.base.PageRequest;
import com.mike.employment.po.Recruit;
import com.mike.employment.service.RecruitService;

@RestController
@RequestMapping("/api/recruit")
public class RecruitController {
	
	@Autowired
	private RecruitService recruitService;
	
	@PostMapping("/page")
	public ApiResult getPage(@RequestBody PageRequest pageRequest) {
		return ApiResult.success(recruitService.getPage(pageRequest));
	}
	
	@PutMapping()
	public ApiResult saveOrUpdate(@RequestBody Recruit recruit) {
		return ApiResult.success(recruitService.saveOrUpdate(recruit));
	}
	
	@DeleteMapping()
	public ApiResult delete(@RequestBody Long ...ids) {
		return ApiResult.success(recruitService.delete(ids));
	}
	
	@GetMapping("/{id}")
	public ApiResult find(@PathVariable("id") Long id) {
		return ApiResult.success(recruitService.findById(id));
	}
}
